package com.ruoyi.web.controller.jiugongge;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.jiugongge.domain.WebJwid;
import com.ruoyi.jiugongge.service.IWebJwidService;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.base.AjaxResult;

/**
 * 系统公众号 信息操作处理
 * 
 * @author lzy
 * @date 2019-02-15
 */
@Controller
@RequestMapping("/jiugongge/webJwid")
public class WebJwidController extends BaseController
{
    private String prefix = "jiugongge/webJwid";
	
	@Autowired
	private IWebJwidService webJwidService;
	
	@RequiresPermissions("jiugongge:webJwid:view")
	@GetMapping()
	public String webJwid()
	{
	    return prefix + "/webJwid";
	}
	
	/**
	 * 查询系统公众号列表
	 */
	@RequiresPermissions("jiugongge:webJwid:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(WebJwid webJwid)
	{
		startPage();
        List<WebJwid> list = webJwidService.selectWebJwidList(webJwid);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出系统公众号列表
	 */
	@RequiresPermissions("jiugongge:webJwid:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WebJwid webJwid)
    {
    	List<WebJwid> list = webJwidService.selectWebJwidList(webJwid);
        ExcelUtil<WebJwid> util = new ExcelUtil<WebJwid>(WebJwid.class);
        return util.exportExcel(list, "webJwid");
    }
	
	/**
	 * 新增系统公众号
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存系统公众号
	 */
	@RequiresPermissions("jiugongge:webJwid:add")
	@Log(title = "系统公众号", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(WebJwid webJwid)
	{		
		return toAjax(webJwidService.insertWebJwid(webJwid));
	}

	/**
	 * 修改系统公众号
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") String id, ModelMap mmap)
	{
		WebJwid webJwid = webJwidService.selectWebJwidById(id);
		mmap.put("webJwid", webJwid);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存系统公众号
	 */
	@RequiresPermissions("jiugongge:webJwid:edit")
	@Log(title = "系统公众号", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(WebJwid webJwid)
	{		
		return toAjax(webJwidService.updateWebJwid(webJwid));
	}
	
	/**
	 * 删除系统公众号
	 */
	@RequiresPermissions("jiugongge:webJwid:remove")
	@Log(title = "系统公众号", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(webJwidService.deleteWebJwidByIds(ids));
	}
	
}
